<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1" %>

<%!boolean isNatural(String s) {
		try {
			Integer.parseInt(s);
			return true;
		} catch (Exception e) {
			return false;
		}
	}%>

<%
if(isNaturallllllllllllllllllllllllllllllllll(request.getParameter("largeur")) && isNatural(request.getParameter("hauteur"))){
	int lastLignes = (int)request.getSession().getAttribute("hauteur");
	int lastColonnes = (int)request.getSession().getAttribute("largeur");
}
		




%>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Damier 2</title>
</head>
<body>
	<form action="#" method="get">
		Nom : <input type="text" name="nom"
			value="<%if (request.getParameter("nom") != null) {

				out.println(request.getParameter("nom"));
			} else {
				out.println("");
			}%>" /><br />
		Lignes : <input type="text" name="hauteur"
			value="<%if (request.getParameter("hauteur") != null) {

				out.println(request.getParameter("hauteur"));
			} else {
				out.println("");
			}%>" />
		Colonnes : <input type="text" name="largeur"
			value="<%if (request.getParameter("largeur") != null) {
				out.println(request.getParameter("largeur"));
			} else {
				out.println("");
			}%>" />&nbsp;
		&nbsp; <input type="submit" value="rafraîchir" />
	</form>
	<h1>
		<%
			if (request.getParameter("nom") != null
					&& isNatural(request.getParameter("largeur"))
					&& isNatural(request.getParameter("hauteur"))) {%>
					
					
					Ancienne valeur de lignes : <%=request.getSession().getAttribute("lastLignes") %> <br />
					Ancienne valeur de Colonnes : <%=request.getSession().getAttribute("lastColonnes") %><br />

				<%out.println(request.getParameter("nom") + "&nbsp;"
						+ request.getParameter("hauteur") + "x"
						+ request.getParameter("largeur") + "&nbsp"
						+ "<< Mon beau damier>>");
			}
		%>
	</h1>
	
		<%
			if (isNatural(request.getParameter("hauteur"))
					&& isNatural(request.getParameter("largeur"))) {
				int l = Integer.parseInt(request.getParameter("hauteur"));
				int h = Integer.parseInt(request.getParameter("largeur"));%>
				<table border="1" cellpadding="7">

				<%for (int i = 0; i < l; i++) {
		%>
		<tr>
			<%
				for (int j = 0; j < h; j++) {
			%>

			<td style=" <%if ((i+j)%2 == 0) out.println("background-color: black;");%> "></td>

			<%
				}
			%>
		</tr>
		<%
			}
		%>
		</table>
		<%
			}
		%>
		
</body>
</html>